package com.client.rule;

import java.util.Map;

import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.Node;
import com.shared.data.IData;
import com.shared.rule.TypeDataRule;



public abstract class UiRule extends TreeItem{
	
	protected String label;
	
	
	
	public UiRule() {
		super();
		label = "rule";
		setText(label);
	}
	
	public UiRule(Map<String,TypeDataRule> availableData) {
		super();
		label = "rule";
		setText(label);
	}
	
	public UiRule(int nbRules){
		super();
		label = "rule"+(nbRules+1);
		setText(label);
	}
	
	public UiRule(String l) {
		super();
		label = l;
		setText(label);
	}
	
		
	public abstract boolean isComposite();
	
	public abstract void generateFromXML(Node xmlNode);
	
	public abstract String toXml(Map<String,TypeDataRule> mapData);
	
	public abstract void getUsedDataXml(Map<String,String> usedData,Map<String,TypeDataRule> mapData);
	
	public boolean hasRule(){
		return getChildCount()==0;
	}
	/**
	 * @param label the label to set
	 */
	public void setLabel(String label) {
		this.label = label;		
	}

	/**
	 * @return the label
	 */
	public String getLabel() {
		return label;
	}

	
}
